package com.example;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;
import de.greenrobot.daogenerator.ToMany;

public class ExampleDaoGenerator
{

    public static void main(String[] args) throws Exception
    {

        Schema schema = new Schema(1, "greendao");



        addNote(schema);

        addLoreDetail(schema);

        new DaoGenerator().generateAll(schema,
                "/Users/mac/Desktop/1601/Projects/Project_Template/app/src/main/java-greendao");
    }

    private static void addLoreDetail(Schema schema)
    {
        Entity loreDetail = schema.addEntity("LoreDetailTable");

        loreDetail.addIdProperty();

        loreDetail.addStringProperty("title").notNull().unique();

        loreDetail.addStringProperty("imageUrl").notNull();

        loreDetail.addLongProperty("time");

    }

    /**
     * @param schema
     */
    private static void addNote(Schema schema)
    {
        Entity note = schema.addEntity("NoteTable");

        note.setTableName("NoteTable");

        note.addIdProperty();

        note.addStringProperty("text").notNull();

        note.addStringProperty("comment");

        note.addDateProperty("date");
    }

    private static void addCustomerOrder(Schema schema)
    {
        Entity customer = schema.addEntity("Customer");
        customer.addIdProperty();
        customer.addStringProperty("name").notNull();

        Entity order = schema.addEntity("Order");
        order.setTableName("ORDERS"); // "ORDER" is a reserved key<a href="http://www.it165.net/edu/ebg/" target="_blank" class="keylink">word</a>

        order.addIdProperty();
        Property orderDate = order.addDateProperty("date").getProperty();
        Property customerId = order.addLongProperty("customerId").notNull().getProperty();
        order.addToOne(customer, customerId);

        ToMany customerToOrders = customer.addToMany(order, customerId);
        customerToOrders.setName("orders");
        customerToOrders.orderAsc(orderDate);
    }
}
